<?php
error_reporting(E_ALL ^ E_NOTICE); 
// 用户名 用户Email 标题 纯文本body htmlbody 
function sendemail($TPusername,$TPemail,$TPheader,$TPbody,$TPbody_HTML){
	
require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

$body             = $TPbody_HTML;

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = C('EMAIL_SERVER_HOST'); // SMTP server
//$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = C('EMAIL_SERVER_HOST'); // sets the SMTP server
$mail->Port       = C('EMAIL_SERVER_PORT');                    // set the SMTP port for the GMAIL server
$mail->Username   = C('EMAIL_SERVER_USERNAME'); // SMTP account username
$mail->Password   = C('EMAIL_SERVER_PWD');        // SMTP account password

$mail->SetLanguage('zh_cn');
$mail->CharSet    = "utf-8";

$mail->SetFrom(C('EMAIL_ADDRESS'), C('SITE_NAME'));

$mail->AddReplyTo(C('EMAIL_ADDRESS'),C('SITE_NAME'));

$mail->Subject    = $TPheader;

$mail->AltBody    = $TPbody; // optional, comment out and test

$mail->MsgHTML($body);

$address = $TPemail;
$mail->AddAddress($address, $TPusername);


if(!$mail->Send()) {
  return $mail->ErrorInfo;
} else {
  return true;
}
}
?>